/**
 入驻小区
 **/
(function (vc) {
    var DEFAULT_PAGE = 1;
    var DEFAULT_ROWS = 10;
    vc.extends({
        data: {
            goldBusinessManageInfo: {
                goldBusinesss: [],
                total: 0,
                records: 1,
                moreCondition: false,
                scId: '',
                conditions: {
                    amount: '',
                    busiId: '',
                    buyerName: '',
                    state: '',
                    communityId: '',
                    communityName: '',
                    shopId: vc.getCurrentCommunity().shopId
                }
            }
        },
        _initMethod: function () {
            $that._listgoldBusinesss(DEFAULT_PAGE, DEFAULT_ROWS);
        },
        _initEvent: function () {
            vc.on('goldBusinessManage', 'listgoldBusiness', function (_param) {
                $that._listgoldBusinesss(DEFAULT_PAGE, DEFAULT_ROWS);
            });
            vc.on('pagination', 'page_event', function (_currentPage) {
                $that._listgoldBusinesss(_currentPage, DEFAULT_ROWS);
            });
        },
        methods: {
            _listgoldBusinesss: function (_page, _rows) {
                $that.goldBusinessManageInfo.conditions.page = _page;
                $that.goldBusinessManageInfo.conditions.row = _rows;
                var param = {
                    params: $that.goldBusinessManageInfo.conditions
                };
                param.params.busiId = param.params.busiId.trim();
                param.params.amount = param.params.amount.trim();
                param.params.buyerName = param.params.buyerName.trim();
                //发送get请求
                vc.http.apiGet('/goldBusiness/queryGoldBusiness',
                    param,
                    function (json, res) {
                        var _goldBusinessManageInfo = JSON.parse(json);
                        $that.goldBusinessManageInfo.total = _goldBusinessManageInfo.total;
                        $that.goldBusinessManageInfo.records = _goldBusinessManageInfo.records;
                        $that.goldBusinessManageInfo.goldBusinesss = _goldBusinessManageInfo.data;
                        vc.emit('pagination', 'init', {
                            total: $that.goldBusinessManageInfo.records,
                            dataCount: $that.goldBusinessManageInfo.total,
                            currentPage: _page
                        });
                    }, function (errInfo, error) {
                        console.log('请求失败处理');
                    }
                );
            },
            //查询
            _querygoldBusinessMethod: function () {
                $that._listgoldBusinesss(DEFAULT_PAGE, DEFAULT_ROWS);
            },
            //重置
            _resetgoldBusinessMethod: function () {
                $that.goldBusinessManageInfo.conditions.busiId = "";
                $that.goldBusinessManageInfo.conditions.amount = "";
                $that.goldBusinessManageInfo.conditions.buyerName = "";
                $that._listgoldBusinesss(DEFAULT_PAGE, DEFAULT_ROWS);
            },
            _moreCondition: function () {
                if ($that.goldBusinessManageInfo.moreCondition) {
                    $that.goldBusinessManageInfo.moreCondition = false;
                } else {
                    $that.goldBusinessManageInfo.moreCondition = true;
                }
            }
        }
    });
})(window.vc);
